package cn.my.framework.activiti.test;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.TaskListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * Created by zhangl_lc on 2017/7/26.
 */
@Service("myExecutionListener")
public class MyExecutionListener  implements ExecutionListener,TaskListener{

    Logger logger = LoggerFactory.getLogger(MyExecutionListener.class);

    @Override
    public void notify(DelegateExecution execution) throws Exception {
        String eventName = execution.getEventName();
        logger.info("+++++execution eventName = {},executionId={},ProcessDefinitionId={},ProcessInstanceId={},ProcessBusinessKey={},CurrentActivityId={}",
                eventName,execution.getId(),execution.getProcessInstanceId(),execution.getProcessBusinessKey(),
                execution.getProcessDefinitionId(),execution.getCurrentActivityId());
    }

    @Override
    public void notify(DelegateTask task) {
        String eventName = task.getEventName();
        logger.info("+++++task eventName = {},taskId={},ProcessInstanceId={},getProcessDefinitionId={}",
                eventName,task.getId(),task.getProcessInstanceId(),task.getProcessDefinitionId());
    }
}
